
package com.linghu.tankgame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;

/**
 * @author 令狐荣豪
 * @version 1.0
 */
public class LinghuTankGame01 extends JFrame {
    MyPanel mp=null;
    public static void main(String[] args) {
        LinghuTankGame01 linghuTankGame01 = new LinghuTankGame01();
    }

    public LinghuTankGame01() {
        mp=new MyPanel();//面板的游戏区域
        Thread thread = new Thread(mp);//子弹线程
        thread.start();
        this.add(mp);

        this.setSize(1300,750);
        //设置好运动状态不要忘了设置它
        this.addKeyListener(mp);//让JFrame监听mp的键盘事件
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        //在Jfram中增加相应关闭窗口的处理
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("监听到关闭窗口了");
                try {
                    Recoder.keepRecoder();
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
                System.out.println(0);
            }
        });
    }
}
